package com.hrl.dao;

import com.hrl.domain.StdInfo;
import com.hrl.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.io.ObjectInputStream;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.text.SimpleDateFormat;

public class StdDao {
    public void addStdInfo(StdInfo std) throws SQLException {
        QueryRunner qr = new QueryRunner();

        String sql = "insert into stdinfo values(?,?,?,?)";

        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date date=new java.util.Date();
        String birth=sdf.format(std.getBirth());
        Object[] param={std.getId(),std.getName(),std.getSex(),birth};

        Connection con = DruidUtils.getConnection();
        int i = qr.update(con, sql, param);

        DruidUtils.close(con);
    }
}
